#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>

#define N 105
#define M 105
using namespace std;

int n,m;
char t[N], p[M][M]; // text, pattern....
int f[M*M]; // Aho-Corasick failure function.
int tt[N]; // Linear space used. (!!!)
int pp[M]; // Changed pattern.
int pf[M]; // KMP prefix function.
int matched[M*M]; // Aho-Corasick output function.
int edge[M*M][30]; // alphabet : 'a'-'z'
int node;
queue<int> q;

int main() {
    int i,j,k,l,c,r;

    // Input
    scanf("%d %d",&m, &n);
    for(i = 0; i < m;i++) {
        scanf("%s",&p[i]);
    }

    // Build a trie for Aho-Corasick
    node = 1;
    f[0] = 0; 
    for(i = 0; i < m;i++){
        c = 0;
        for(j = 0; j < m; j++){
            k = p[i][j]-'a';
            if (edge[c][k] != 0){
                c = edge[c][k];
            } else {
                edge[c][k]=node;
                c = node++;
            }
        }
        if (matched[c] != 0) {
            pp[i] = matched[c];
        } else {
            pp[i] = i+1;
            matched[c] = i+1;
        }
    }

    // BFS to make failure functions by Aho-Corasick.
    int u,v;
    q.push(0);
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(i = 0; i < 26; i++) {
            if (edge[u][i] == 0) continue;
            v = edge[u][i];
            q.push(v); 
            r = f[u];
            while (r != 0 && edge[r][i]==0) {
                r = f[r];
            }
            if (u ==0 || edge[r][i] == 0) {
                f[v] = 0;
            } else {
                f[v] = edge[r][i];
                if (matched[f[v]]!=0){
                    printf("ERROR! impossible matched[f[v]]!=0\n");
                }
            }
        }
    }

    // Compute prefix function of KMP.
    k = 0;
    for(i = 1; i < m;i++){
        while( k > 0 && pp[k] != pp[i])
            k = pf[k];
        if (pp[k] == pp[i])
            k++;
        pf[i] = k; 
    }

    // Match line by line to use linear space.
    for(i = 0; i < n;i++){ 
        scanf("%s", &t);
        c = 0;
        for(j = 0; j < n; j++){
            k = 0;
            while(c > 0 && edge[c][t[j]-'a'] == 0)
                c = f[c];
            if (edge[c][t[j]-'a'] != 0) {
                c = edge[c][t[j]-'a'];
                if (matched[c] != 0) {
                    k = matched[c];
                }
            }
            // tt[j] remembers KMP statenumber.
            while(tt[j] > 0 && pp[tt[j]] != k)
                tt[j] = pf[tt[j]];
            if (pp[tt[j]] == k)
                tt[j]++;
            if (tt[j] == m){
                // There is a match.
                printf("%d %d\n", i, j);
                tt[j] = pf[tt[j]];
            }
        }
    }

    return 0;
}
